$(function() {
	$('#vue_vm_list').hide();
});

function lease_findLeaseRecord() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list').hide();
	var startYear = $('#startYear').val();
	var startMonth = $('#startMonth').val();
	var startDay = $('#startDay').val();
	var endYear = $('#endYear').val();
	var endMonth = $('#endMonth').val();
	var endDay = $('#endDay').val();
	var leaseStatus = parseInt($('#leaseStatus').val());
	var startTime = getStandardDay(startYear, startMonth, startDay);
	var endTime = getStandardDay(endYear, endMonth, endDay);
	
	if(isEmpty(startYear)) {
		alert('请输入开始年');
		return;
	}
	if(isEmpty(startMonth)) {
		alert('请选择开始月');
		return;
	}
	if(isEmpty(startDay)) {
		alert('请选择开始日');
		return;
	}
	if(isEmpty(endYear)) {
		alert('请输入结束年');
		return;
	}
	if(isEmpty(endMonth)) {
		alert('请选择结束月');
		return;
	}
	if(isEmpty(endDay)) {
		alert('请选择结束日');
		return;
	}
	if(isEmpty(startTime)) {
		alert('请输入开始时间');
		return;
	}
	if(isEmpty(endTime)) {
		alert('请输入结束时间');
		return;
	}
	if(isEmpty(leaseStatus)) {
		alert('请选择在租、退租');
		return;
	}
	
	find_basic_by_json(path+'/lease/findLeaseRecord',
		{dateSince: startTime, dateEnd: endTime, leaseStatus: leaseStatus}, function(response) {	
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			},
			methods: {
				getPayWayName:function(payWay) {
					var payWayName = '其他';
					
					switch(payWay) {
						case 1:
							payWayName = '现金';
							break;
						case 2:
							payWayName = '钱包扣费';
							break;
						case 3:
							payWayName = '五保免租金';
							break;
						case 4:
							payWayName = '五保免租金押金';
							break;
					}
					
					return payWayName;
				},
				
				dateDiff: function(sDate1, sDate2) {
					return DateDiff(sDate1, sDate2);
				},
				
				getNowDate: function() {
					return getNowFormatDate().substr(0,10);
				},
				
				getNowDiff: function(sDate1) {
					var nowDate = getNowFormatDate().substr(0,10);
					return DateDiff(nowDate, sDate1);
				},
				
				getNowDiffText: function(sDate1) {
					var nowDiff = this.getNowDiff(sDate1);
					return nowDiff>=0?'还有'+nowDiff+'天到期':'已经超期'+(-nowDiff)+'天';
				},
				
				getNowDiffStart: function(sDate2) {
					var nowDate = getNowFormatDate().substr(0,10);
					var nowDiff = DateDiff(nowDate, sDate2);
					return nowDiff;
				}
			}
		});
		
		$('#vue_vm_list').show();
	});
}